package com.gdcn.report.ajax;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class FindYearAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int id=Integer.parseInt(request.getParameter("year"));
		Class.forName("oracle.jdbc.OracleDriver").newInstance();
		Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.18.8.12:1521:eprbi", "eprbi", "eprbi");
		PreparedStatement ps = conn.prepareStatement("select output from MY_FIRST_IREPORT where year="+id);
		ResultSet rs = ps.executeQuery();
		while(rs.next()) {
			response.getWriter().print("<option value="+rs.getString(1)+">"+rs.getString(1)+"</option>");
		}
//		return super.execute(mapping, form, request, response);
		return null;
	}

}
